home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / checkbox / plugins / suites_info.py < prev    next >
Encoding:
Python Source  |  2009-04-27  |  2.4 KB  |  70 lines

  1. #
  2. # This file is part of Checkbox.
  3. #
  4. # Copyright 2008 Canonical Ltd.
  5. #
  6. # Checkbox is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # Checkbox is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with Checkbox.  If not, see <http://www.gnu.org/licenses/>.
  18. #
  19. from checkbox.lib.template_i18n import TemplateI18n
  20.  
  21. from checkbox.properties import List, Path, String
  22. from checkbox.plugin import Plugin
  23. from checkbox.test import Test
  24.  
  25.  
  26. class SuitesInfo(Plugin):
  27.  
  28.     # Space separated list of directories where suite files are stored.
  29.     directories = List(type=Path(),
  30.         default_factory=lambda:"%(checkbox_share)s/suites")
  31.  
  32.     # Executable path for running scripts. These might be
  33.     # referenced from the above suites for example.
  34.     scripts_path = Path(default="%(checkbox_share)s/scripts")
  35.  
  36.     # Data path containing files for scripts.
  37.     data_path = Path(default="%(checkbox_share)s/data")
  38.  
  39.     # List of suites to blacklist
  40.     blacklist = List(type=String(), default_factory=lambda:"")
  41.  
  42.     # List of suites to whitelist
  43.     whitelist = List(type=String(), default_factory=lambda:"")
  44.  
  45.     def register(self, manager):
  46.         super(SuitesInfo, self).register(manager)
  47.         self._manager.reactor.call_on("gather", self.gather)
  48.  
  49.     def gather(self):
  50.         template = TemplateI18n("suite", ["name"])
  51.         elements = template.load_directories(self.directories,
  52.             self.blacklist, self.whitelist)
  53.  
  54.         for element in elements:
  55.             long_ext = "_extended"
  56.             for long_key in element.keys():
  57.                 if long_key.endswith(long_ext):
  58.                     short_key = long_key.replace(long_ext, "")
  59.                     element[short_key] = element.pop(long_key)
  60.  
  61.             test = Test(self._manager.registry, **element)
  62.             for command in test.command, test.description:
  63.                 command.add_path(self.scripts_path)
  64.                 command.add_variable("data_path", self.data_path)
  65.  
  66.             self._manager.reactor.fire("test-%s" % test.plugin, test)
  67.  
  68.  
  69. factory = SuitesInfo
  70.